package com.treasure.hunt.mode

import android.app.Application
import androidx.lifecycle.MutableLiveData
import com.blankj.utilcode.util.LogUtils
import com.module.lemlin.base.BaseViewModel
import com.module.lemlin.mode.ViewModelSubscribe
import com.module.lemlin.rxhttp.HttpServiceData
import com.module.lemlin.rxhttp.HttpServiceResponse
import com.treasure.hunt.api.*
import com.treasure.hunt.entity.*
import io.reactivex.rxjava3.disposables.Disposable

class OtherViewMode(application: Application) : BaseViewModel(application) {

    val otherConfigLiveData = MutableLiveData<HttpServiceResponse<OtherConfigResponse>>()
    val otherImageLiveData = MutableLiveData<HttpServiceResponse<OtherImageResponse>>()
    val otherUrlLiveData = MutableLiveData<HttpServiceResponse<OtherUrlResponse>>()
    val baseLiveData = MutableLiveData<HttpServiceResponse<HttpServiceData>>()
    val buddyListLiveData = MutableLiveData<HttpServiceResponse<BuddyResponse>>()

    fun otherGetConfig(name: String) {
        val disposable: Disposable =
            otherGetConfig(name, ViewModelSubscribe(otherConfigLiveData))
        dispose.add(disposable)
    }

    fun otherGetImage(name: String) {
        val disposable: Disposable =
            otherGetImage(name, ViewModelSubscribe(otherImageLiveData))
        dispose.add(disposable)
    }

    fun otherShareImage(type: Int, card_id: Int = 0) {
        val disposable: Disposable =
            otherShareImage(
                type.toString(), card_id.toString(),
                ViewModelSubscribe(otherUrlLiveData)
            )
        dispose.add(disposable)
    }

    fun otherAddFeedback(content: String, type: Int) {
        val disposable: Disposable =
            otherAddFeedback(content, type, ViewModelSubscribe(baseLiveData))
        dispose.add(disposable)
    }

    fun otherGetFriendsList() {
        val disposable: Disposable =
            otherGetFriendsList(ViewModelSubscribe(buddyListLiveData))
        dispose.add(disposable)
    }

}